<?php use_helper('I18N') ?>

	<script>
	$(document).ready(function(){
      $("#ecashAmount").focus(function () {
             $(this).blur();
      });
    });
    
    $(function() {
		$("#withdrawForm").validate({
            messages : {
                transactionPassword: {
                    remote: "Transaction Password is not valid."
                }
            },
            rules : {
                "transactionPassword" : {
                    required : true
                    , remote: "/member/verifyTransactionPassword"
                }
            },
            submitHandler: function(form) {
                var amount = $('#ecashAmount').autoNumericGet();
                if (parseFloat($("#ecashBalance").val()) < parseFloat(amount)) {
					alert("In-sufficient E-Cash");
					return false;
				}

                $("#ecashAmount").val(amount);
                form.submit();
            }
        });
	});
	
	function changeAmount(){
		document.getElementById('ecashAmount').value = document.withdrawForm.cbo_ecashAmount.options[document.withdrawForm.cbo_ecashAmount.selectedIndex].text;
		document.getElementById('ecashDeduct').value = document.withdrawForm.cbo_ecashAmount.value;
	}
	</script>

<form action="/member/ecashWithdrawal" id="withdrawForm" name="withdrawForm" method="post">
<table cellpadding="0" cellspacing="5" align="center" border="0">
    <tr>
        <td>
			<font color='white'><?php echo __('E-Cash Balance'); ?></font>
		</td>
		<td>
			<input name="ecashBalance" id="ecashBalance" tabindex="1" disabled="disabled" value="<?php echo number_format($TblAccount->getFBalance(),2,'.',''); ?>"/>
		</td>
    </tr>
    <tr>
        <td>
			<font color='white'><?php echo __('E-Cash Withdraw Amount'); ?></font>
		</td>
		<td>
			<select name="cbo_ecashAmount" id="cbo_ecashAmount" tabindex="2" onChange="changeAmount()">
			<option value="550">500</option>
			<option value="1100">1000</option>
			<option value="1650">1500</option>
			<option value="2200">2000</option>
			<option value="2750">2500</option>
			<option value="3300">3000</option>
			<option value="3850">3500</option>
			<option value="4400">4000</option>
			<option value="4950">4500</option>
			<option value="5500">5000</option>
			</select>
			<input type="hidden" name="ecashAmount" id="ecashAmount" value="250">
			<input type="hidden" name="ecashDeduct" id="ecashDeduct" value="255">
		</td>
    </tr>
    <tr>
        <td>
			<font color='white'><?php echo __('Transaction Password'); ?></font>
		</td>
		<td>
			<input name="transactionPassword" type="password" id="transactionPassword" tabindex="3" />
		</td>
    </tr>
    <tr>
    	<td colspan=2><font color="#dc143c"> <?php echo __('charge 10% handling fees when withdrawal requested') ?></font></td>
    </tr>
    <tr>
    	<td colspan=2 align='center'>
    	<?php if ($sf_flash->has('errorMsg')): ?>
			<span class="error-font"><?php echo $sf_flash->get('errorMsg') ?></span>
		<?php endif; ?>
		<?php if ($sf_flash->has('successMsg')): ?>
			<span class="font"><?php echo $sf_flash->get('successMsg') ?></span>
		<?php endif; ?>
    	</td>
    </tr>
    <tr>
        <td colspan=2 align='center'>
			<input type="submit" name="Button1" value="<?php echo __('Submit') ?>" language="javascript" id="btnTransfer" tabindex="5"/>
		</td>
    </tr>
</table>
</form>